using System;
using System.Collections.Generic;
using System.Text;
using DAP;
using Dominio;

namespace Presenters
{
    public class MyAccountPresenter
    {
        private UserRepository<User> repository;
        private QuestionRepository Qrepository;

        public MyAccountPresenter()
        {
            repository = new UserRepository<User>();
            Qrepository = new QuestionRepository();
        }

        public User getUserById(int user)
        {
            return repository.getUserById(user);
        }

        public void createQuestion(String subject, String question, object author, Bug bug)
        {
            Question pregunta = new Question(subject, question, (User)author, bug, bug.Tester);
            Qrepository.createQuestion(pregunta);
        }

        public void createAnswer(String subject, String answer, object author, Question question)
        {
            Answer respuesta = new Answer(subject, answer, (User)author, question);
            Qrepository.createAnswer(respuesta);
        }

        public IList<Question> getAllQuestion(object user , int bug)
        {
            return Qrepository.getAllFilteredQuestions((User)user, bug);
        }

        public Question getQuestionById(int id)
        {
            return Qrepository.getQuestionById(id);
        }

        public void updateUser(User user)
        {
            repository.save(user);
        }
    }
}
